# -*- coding:utf-8 -*-
from datetime import datetime

from django.db import models

from users.models import UserProfile
from cookbook.models import Menu


class UserFavorite(models.Model):
    user = models.ForeignKey(UserProfile, verbose_name=u'用户')
    menu = models.ForeignKey(Menu, verbose_name=u'菜谱名')
    is_fav = models.BooleanField(u'是否关注', default=True)
    add_time = models.DateTimeField(u'添加时间', default=datetime.now)

    class Meta:
        verbose_name = u'用户收藏'
        verbose_name_plural = verbose_name

    def __unicode__(self):
        return '{0}({1})'.format(self.user, self.menu)


class UserConcern(models.Model):
    user_id = models.IntegerField(u'用户ID')
    to_user = models.ForeignKey(UserProfile, verbose_name=u'被关注用户')
    status = models.CharField(u'关注状态', choices=(('true', u'已关注'), ('false', u'取消关注')), max_length=8)
    is_concern = models.BooleanField(u'是否关注', default=True)
    add_time = models.DateTimeField(u'添加时间', default=datetime.now)

    class Meta:
        verbose_name = u'用户关注'
        verbose_name_plural = verbose_name

    def __unicode__(self):
        return '{0}-->{1}'.format(self.user_id, self.to_user)